<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
function deepClone( obj = {} ){

    if( typeof obj !== 'object' || obj == null ){
        return obj
    }

    let result
    if( obj instanceof Array ){
        result = []
    } else {
        result = {}
    }

    for( let key in obj ){
        if( obj.hasOwnProperty(key) ){
            result[key] = deepClone( obj[key] )
        }
    }

    return result
}
    </script>
</body>
</html>